1. Field of the Invention
The present invention relates to data storage devices with flash memory and flash memory control methods.
2. Description of the Related Art
Flash memory is commonly used in data storage devices as a storage medium. NAND flash is a common flash memory.
Flash memory is typically used in memory cards, USB flash devices, solid-state drives (SSDs), and so on. In another application with multi-chip package technology, a NAND flash chip and a controller chip are combined in one package as an embedded multi-media card (eMMC).
A flash memory provides a storage area which is divided into blocks, and each block includes a plurality of pages. The space of one block is reused after the entire block is erased. When updating data stored in the flash memory, the new data is written into a spare area rather than being overwritten onto the old data and the old data is regarded invalid. Thus, the storage area management of the flash memory is different and more complex than the other types of storage mediums. Generally, a logical-to-physical address mapping relationship between the host and the flash memory is recorded in the flash memory for the storage space management. The logical-to-physical address mapping relationship has to be updated when the host writes data into the flash memory. If a power failure event occurs during the update of the logical-to-physical address mapping relationship, the logical-to-physical address mapping relationship recorded in the flash memory may be unreliable (not updated in time). During the power recovery process, it may waste a lot of time to scan all blocks of the flash memory for restoring the correct logical-to-physical address mapping relationship in the flash memory.